<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>注册</title>
    <link rel="stylesheet" href="./layui/css/layui.css">
    <script type="text/javascript" src="./layui/layui.all.js"></script>
    <script type="text/javascript" src="./layui/layui.js"></script>
</head>

<body class="layui-layout-body">
<div class="layui-layout layui-layout-admin">
    <div class="layui-header">
        <div class="layui-logo">日记系统注册管理区</div>
        <!-- 头部区域（可配合layui已有的水平导航） -->
        <ul class="layui-nav layui-layout-left ">
            <li class="layui-nav-item"><a href="">控制台</a></li>
        </ul>

    </div>

    <div class="layui-side layui-bg-black">
        <div class="layui-side-scroll">
            <!-- 左侧导航区域（可配合layui已有的垂直导航） -->
            <ul class="layui-nav layui-nav-tree" lay-filter="test">
                <li class="layui-nav-item layui-nav-itemed">
                    <a class="" href="javascript:;">所有功能</a>
                    <dl class="layui-nav-child">
                        <dd><a href="/login.html">注册界面</a></dd>
                        <dd><a href="/loginSuccess.html">登陆界面</a></dd>
                    </dl>
                </li>

            </ul>
        </div>
    </div>

    <div class="layui-body"><br><br>
        <h1 style="margin-left: 42px;color: #1E9FFF"><strong>注册界面</strong></h1><br><br>
        <form action="/login" method="post" class="layui-form" onsubmit="return submit1()">
            <div class="layui-form-item">
                <label class="layui-form-label">用户名:</label>
                <div class="layui-input-inline">
                    <input class="layui-input" type="text" name="name" lay-verify="required" class="layui-input"
                           lay-reqtext="用户名是必填项，岂能为空？" placeholder="请输入用户名" id="username" onblur="Name()">
                </div>
                <label id="label"></label>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">密码:</label>
                <div class="layui-input-inline"><input class="layui-input" type="text" name="pwd" placeholder="请输入密码"
                                                       id="pwd" onblur="Pwd()">
                </div>
                <label id="label2"></label>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">邮箱:</label>
                <div class="layui-input-inline"><input class="layui-input" type="text" name="email" placeholder="请输入邮箱"
                                                       id="email" onblur="Email()">
                </div>
                <label id="label3"></label>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">性别:</label>
                <div class="layui-input-inline"><input class="layui-input" type="text" name="sex" placeholder="男/女"
                                                       id="sex" onblur="Sex()">
                </div>
                <label id="label4"></label>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">验证码:</label>
                <div class="layui-input-inline"><input class="text  layui-input" type="text" name="captcha"
                                                       placeholder="请输入验证码">
                </div>
                <img src="/captcha" id="captchImg" class="captcha">
                <a href="javascript:Captcha()" style="color: #1E9FFF ;margin-left: 14px;"> 验证码看不清，点这里 </a>
            </div>
            <input type="submit" style="margin-left: 111px;" class="layui-btn" value="注册" id=submit>
        </form>
        <!-- 内容主体区域 -->
    </div>


    <div class="layui-footer">
        <!-- 底部固定区域 -->
        © gaoyuan.com - 底部固定区域
    </div>
</div>
</div>
<script src="../src/layui.js"></script>
<script>
    //JavaScript代码区域
    layui.use('element', function () {
        var element = layui.element;

    });
    var captch = document.getElementById("captchImg").value;
    console.log(captch);
    var username = document.getElementById("username");
    var label = document.getElementById("label");

    function Name() {
        if (username.value != null && username.value != "") {
            label.innerHTML = "";
        } else {
            label.innerHTML = "请输入用户名";

            username.focus();
            console.log(username.value);
            label.style.color = "red";
        }

    };

    function Captcha() {

        var captchaImg = document.getElementById("captchImg");
        captchaImg.src = "/captcha?t=" + (new Date()).getTime();

    }


    var pwd = document.getElementById("pwd");
    var label2 = document.getElementById("label2");

    function Pwd() {
        if (pwd.value != null && pwd.value != "") {
            label2.innerHTML = "";
        } else {
            label2.innerHTML = "请输入密码";
            label2.style.color = "red";
        }

    };
    var email = document.getElementById("email");
    var label3 = document.getElementById("label3");
    var Email1 = /^([a-zA-Z]|[0-9])(\w|\-)+@[a-zA-Z0-9]+\.([a-zA-Z]{2,4})$/;

    function Email() {
        if (email.value != null && email.value != "") {
            var a = Email1.test(email.value);
            if (!a) {
                label3.innerHTML = "亲输入正确邮箱格式！";
                email.value = "";
                email.focus();
                console.log(a);
            } else {
                label3.innerHTML = "";
            }

        } else {
            label3.innerHTML = "请输入邮箱";
            label3.style.color = "red";
        }

    };
    var sex = document.getElementById("sex");
    var label4 = document.getElementById("label4");

    function Sex() {
        if (sex.value != null && sex.value != "") {
            if (sex.value != "男" && sex.value != "女") {
                label4.innerHTML = "请输入正确性别";

                label4.style.color = "red";
            } else {
                label4.innerHTML = ""
            }
        } else {
            label4.innerHTML = "请输入性别";
            label4.style.color = "red";
        }

    };

    function submit1() {
        if (username.value == "" || pwd.value == "" || sex.value == "" || email.value == "") {
            return false;
        }
        return true;
    };


</script>

</body>


</html>